package com.example.controller;

import com.example.common.ResultBody;
import com.example.entity.User;
import com.example.service.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @author yeweilin
 */
@RestController
@RequestMapping("/user")
public class AclController {
     @Autowired
     private UserServiceImpl userService;
    @PostMapping("/login")
    public ResultBody<Map<String,Object>> login(@RequestBody User user){
        return userService.login(user);
    }
    @GetMapping("/hello")
    @PreAuthorize(value = "hasAnyAuthority('permissionssss')")
    public String hello(){
        return "hello";
    }

    @PostMapping("/logout")
     public ResultBody logout(HttpServletRequest request){
        ResultBody logout = userService.logout(request);
        return logout;
    }
}
